package com.lin.threadtest;
/**
 * 多线程实现Runnable接口
 * @author Zhang
 *
 */
public class RunnableTest implements Runnable{
	
	private String name;
	
	public RunnableTest(String name) {
		super();
		this.name = name;
	}


	@Override
	public void run() {
		for (int i = 1; i <= 3; i++) {
			
			int num = (int)(Math.random()*10);
			System.out.println(name+"-第"+i+"次运行-"+"sleep:"+num);
			try {
				Thread.sleep(num*1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		new Thread(new RunnableTest("runnable线程1")).start();
		new Thread(new RunnableTest("runnable线程2")).start();
	}

}
